<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/commons/jsp/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@taglib uri="http://www.framework.com/taglib/tree" prefix="tree"%>
  <head>
	<title>公共平台 </title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	
	<script type="text/javascript">
	   var UEDITOR_HOME_URL ="${ctx}/ueditor/"; 
	</script>
	
	 <script type="text/javascript" charset="utf-8" src="${ctx}/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="${ctx}/ueditor/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="${ctx}/ueditor/lang/zh-cn/zh-cn.js"></script>
	
	<script src="${ctx}/ueditor/ueditor.parse.js"></script>
	
	<!-- 样式文件的引入 -->
	<link href="${ctx}/commons/css/style.css" rel="stylesheet" type="text/css"/>
	<link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/icon.css">
	<link href="${ctx}/fckeditor/_samples/sample.css" rel="stylesheet" type="text/css" />  
	
<!-- 	<script type="text/javascript" src="${ctx}/fckeditor/fckeditor.js"></script>   -->
	
	<style type="text/css">
		li{
			padding-top:8px;
		}
	</style>
	<!-- jqueryUI JS文件的引入 -->
	<script type="text/javascript" src="${ctx}/commons/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="${ctx}/commons/js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${ctx}/commons/js/easyui-extends-validate.js"></script>
	<!-- jqueryUI国际化 -->
	<script type="text/javascript" src="${ctx}/commons/js/easyui-lang-zh_CN.js"></script>
	<!-- 开发使用的公用js方法 -->
	<script type="text/javascript" src="${ctx}/commons/js/common.js"></script>
	<!-- 开发国际化的引用，主要完成后台信息在前台提示的国际化，一定要放在最后 -->
	<script type="text/javascript">var ctx = '${ctx}';var actionExt = "action";var i18n = new Object();</script>
	<script src="${ctx}/commons/js/i18n/message_zh_CN.js" type="text/javascript"></script>
  </head>
  
  <body>
<form name="addDataForm" id="addGoodsDataForm" method="post" action="${ctx}/business/goodsManage/save" >
	<input type="hidden" name="id" value="${goodsInfo.id}"/>
	<table class="infoTable" style="width: 80%;">
		<tbody>
		<tr>
			<th align="right" width="15%">商品名称</th>
			<td width="35%">
			<c:choose>
				<c:when test="${goodsInfo.isShelve == 1 || goodsInfo.isShelve == 2}">
					${goodsInfo.goodsName}
					<input name="goodsName" type="hidden"  value="${goodsInfo.goodsName}"/>
				</c:when>
				<c:otherwise>
					<input name="goodsName" class="easyui-validatebox" prompt="" data-options="required:true,validType:'isBlank'" size="24" value="${goodsInfo.goodsName}" maxlength="32"/>
				</c:otherwise>
			</c:choose>
			</td>
			<th align="right" width="15%">商品编码</th>
			<td width="35%">
				<c:choose>
					<c:when test="${goodsInfo.isShelve == 1 || goodsInfo.isShelve == 2}">
						${goodsInfo.goodsCode}
						<input type="hidden" name="goodsCode" value="${goodsInfo.goodsCode}"/>
					</c:when>
					<c:otherwise>
						<input class="easyui-textbox" prompt="" data-options="disabled:true" size="24" readonly="readonly" value="${goodsInfo.goodsCode}" maxlength="64"/>
						<input type="hidden" name="goodsCode" value="${goodsInfo.goodsCode}"/>
					</c:otherwise>
				</c:choose>
				
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">商品类型</th>
			<td width="35%">
			<c:choose>
				<c:when test="${goodsInfo.isShelve == 1 || goodsInfo.isShelve == 2}">
				${goodsInfo.goodsTypeName}
					<input name="goodsTypeName" id="goodsTypeName" type="hidden" value="${goodsInfo.goodsTypeName}"/>
					<input type="hidden" name="goodsTypeId" id="goodsTypeId" class="easyui-validatebox" size="30" value="${goodsInfo.goodsTypeId}"/>
				</c:when>
				<c:otherwise>
					<input name="goodsTypeName" id="goodsTypeName" class="easyui-validatebox" readonly="readonly" data-options="required:true" size="24" value="${goodsInfo.goodsTypeName}" maxlength="64"/>
					<input type="hidden" name="goodsTypeId" id="goodsTypeId" class="easyui-validatebox" size="30" value="${goodsInfo.goodsTypeId}"/>
					<span id="pGoodsType" style="width: 100px;height: 100px;"><a href="javascript:void(0);" onclick="selectGoodsType()"><img src="${ctx}/commons/themes/icons/icon3.gif" border="0" title="选择商品类型"/></a></span>
				</c:otherwise>
			</c:choose>
			</td>
			<th align="right" width="15%">商品品牌</th>
			<td>
				<c:choose>
					<c:when test="${goodsInfo.isShelve == 1 || goodsInfo.isShelve == 2}">
					${goodsInfo.goodsBrand}
						<input name="goodsBrand" type="hidden" value="${goodsInfo.goodsBrand}" /></td>
					</c:when>
					<c:otherwise>
						<input name="goodsBrand" class="easyui-validatebox" data-options="required:true,validType:['goodsBrand']" size="24" value="${goodsInfo.goodsBrand}" maxlength="32"/></td>
					</c:otherwise>
				</c:choose>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">商品规格</th>
			<td>
				<c:choose>
					<c:when test="${goodsInfo.isShelve == 1 || goodsInfo.isShelve == 2}">
					${goodsInfo.goodsStandard}
						<input name="goodsStandard" type="hidden" value="${goodsInfo.goodsStandard}" />  
					</c:when>
					<c:otherwise>
						<input name="goodsStandard" class="easyui-validatebox" data-options="required:true,validType:'isBlank'" size="24" value="${goodsInfo.goodsStandard}" maxlength="32"/>  
					</c:otherwise>
				</c:choose>

			</td>
			<th align="right" width="15%">商品型号</th>
			<td>
				<c:choose>
					<c:when test="${goodsInfo.isShelve == 1 || goodsInfo.isShelve == 2}">
						${goodsInfo.goodsNum}
						<input name="goodsNum" type="hidden" value="${goodsInfo.goodsNum}" />
					</c:when>
					<c:otherwise>
						<input name="goodsNum" class="easyui-validatebox" data-options="required:true,validType:['isBlank']" size="24" value="${goodsInfo.goodsNum}" maxlength="32"/>
					</c:otherwise>
				</c:choose>
			</td>
		</tr>
		<tr>
<%--			<th align="right" width="15%">商品原价</th>--%>
<%--		<td><input name="oldPrice" class="easyui-validatebox" data-options="required:true,validType:['priceDecimal']" size="24" value="${goodsInfo.oldPrice}" maxlength="64"/></td>--%>
<%--			</td>--%>
			<th align="right" width="15%">在售价(元)</th>
			<td><input type="hidden" name="oldPrice" value="0"/>
				<input name="sellPrice" id="sellPrice" class="easyui-validatebox" prompt="请输入商品名称" data-options="required:true,validType:['priceDecimal']" size="24" value="${goodsInfo.sellPrice}" maxlength="10"/>  
			</td>
			<th align="right" width="15%">商品库存</th>
			<td><input name="goodsStorage" class="easyui-validatebox" size="10" value="${goodsInfo.goodsStorage}" data-options="required:true,validType:['positiveInteger']" maxlength="10"/> 件
			</td>
		</tr>
		<tr>
			
			<th align="right" width="15%">是否推荐</th>
			<td colspan="3">
				<input type="radio" value="0" <c:if test="${empty goodsInfo.isRecommend or goodsInfo.isRecommend == 0}">checked="checked"</c:if> name="isRecommend"/>不推荐
				<input type="radio" value="1" <c:if test="${goodsInfo.isRecommend == 1}">checked="checked"</c:if> name="isRecommend"/>推荐
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">价格梯度</th>
			<td colspan="3">
					
					<a href="javascript:void(0);" onclick="addPriceGrads(this)" class="easyui-linkbutton" iconCls="icon-add" plain="true">增加价格梯度</a>
				<ul style="margin-top:10px;">
					<c:forEach items="${goodsPriceGrads}" var="grad">
						<li>
							<input name="startCounts" class="easyui-validatebox" size="10" value="${grad.startCount}" data-options="required:true,validType:['positiveInteger']" maxlength="16"/> 件以上
							<input name="roomPrices" class="easyui-validatebox" size="10" value="${grad.roomPrice}" data-options="required:true,validType:['priceDecimal']" maxlength="16"/> 元              
							<a href="javascript:void(0);" onclick="$(this).parent().remove()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
						</li>
					</c:forEach>
				</ul>
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">绑定图片</th>
			<td colspan="3">
			<c:choose>
				<c:when test="${goodsInfo.isShelve == 1 || goodsInfo.isShelve == 2}">
					<div style="width: 100%;height: 40px;"><a href="${ctx }/file_resource${dto.viewFilePath}" id="view_view" <c:if test="${empty dto.viewId}">style="display: none;"</c:if> target="_blank" class="easyui-linkbutton"  plain="true">浏览图片</a>&nbsp;&nbsp;<span style="font-size: 12px;color: #aaaaaa;">（商品列表展示图，规格：160*160）</span>&nbsp;&nbsp;
				<input type="hidden" name="viewId" id="viewId" value="${dto.viewId }"/></div>
				<div style="width: 100%;height: 40px;"><a href="${ctx }/file_resource${dto.show1FilePath}" id="show_1_view" <c:if test="${empty dto.show1Id}">style="display: none;"</c:if> target="_blank" class="easyui-linkbutton"  plain="true">浏览图片</a>&nbsp;&nbsp;<span style="font-size: 12px;color: #aaaaaa;">（商品详情展示图1，规格：338*295）</span>&nbsp;&nbsp;
				<input type="hidden" name="show1Id" id="show_1Id" value="${dto.show1Id }"/></div>
				<div style="width: 100%;height: 40px;"><a href="${ctx }/file_resource${dto.show2FilePath}" id="show_2_view" <c:if test="${empty dto.show2Id}">style="display: none;"</c:if> target="_blank" class="easyui-linkbutton"  plain="true">浏览图片</a>&nbsp;&nbsp;<span style="font-size: 12px;color: #aaaaaa;">（商品详情展示图2，规格：338*295）</span>&nbsp;&nbsp;
				<input type="hidden" name="show2Id" id="show_2Id" value="${dto.show2Id }"/></div>
				<div style="width: 100%;height: 40px;"><a href="${ctx }/file_resource${dto.show3FilePath}" id="show_3_view" <c:if test="${empty dto.show3Id}">style="display: none;"</c:if> target="_blank" class="easyui-linkbutton"  plain="true">浏览图片</a>&nbsp;&nbsp;<span style="font-size: 12px;color: #aaaaaa;">（商品详情展示图3，规格：338*295）</span>&nbsp;&nbsp;
				<input type="hidden" name="show3Id" id="show_3Id" value="${dto.show3Id }"/></div>
				<div style="width: 100%;height: 40px;"><a href="${ctx }/file_resource${dto.show4FilePath}" id="show_4_view" <c:if test="${empty dto.show4Id}">style="display: none;"</c:if> target="_blank" class="easyui-linkbutton"  plain="true">浏览图片</a>&nbsp;&nbsp;<span style="font-size: 12px;color: #aaaaaa;">（商品详情展示图4，规格：338*295）</span>&nbsp;&nbsp;
				<input type="hidden" name="show4Id" id="show_4Id" value="${dto.show4Id }"/></div>
				
				</c:when>
				<c:otherwise>
					<div style="width: 100%;height: 40px;"><input name="view" id="view" class="easyui-validatebox" data-options="required:true" readonly="readonly" size="30" value="${dto.viewFileName}"/><a href="javascript:void(0);" class="easyui-linkbutton" style="margin-left: 5px;" onclick="selPic('view','-1');"  plain="true">选择图片</a><span style="font-size: 12px;color: #aaaaaa;">（商品列表展示图，规格：160*160）</span>&nbsp;&nbsp;<a href="${ctx }/file_resource${dto.viewFilePath}" id="view_view" <c:if test="${empty dto.viewId}">style="display: none;"</c:if> target="_blank" class="easyui-linkbutton"  plain="true">浏览图片</a>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="deleteBandingFile('view');" <c:if test="${empty dto.viewId}">style="display: none;"</c:if> class="easyui-linkbutton"  plain="true">删除绑定</a>
				<input type="hidden" name="viewId" id="viewId" value="${dto.viewId }"/></div>
				<div style="width: 100%;height: 40px;"><input name="show_1" id="show_1" class="easyui-validatebox" data-options="required:true" readonly="readonly" size="30" value="${dto.show1FileName}"/><a href="javascript:void(0);" class="easyui-linkbutton" style="margin-left: 5px;" onclick="selPic('show_1','-1');"  plain="true">选择图片</a><span style="font-size: 12px;color: #aaaaaa;">（商品详情展示图1，规格：338*295）</span>&nbsp;&nbsp;<a href="${ctx }/file_resource${dto.show1FilePath}" id="show_1_view" <c:if test="${empty dto.show1Id}">style="display: none;"</c:if> target="_blank" class="easyui-linkbutton"  plain="true">浏览图片</a>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="deleteBandingFile('show1');" <c:if test="${empty dto.show1Id}">style="display: none;"</c:if> class="easyui-linkbutton"  plain="true">删除绑定</a>
				<input type="hidden" name="show1Id" id="show_1Id" value="${dto.show1Id }"/></div>
				<div style="width: 100%;height: 40px;"><input name="show_2" id="show_2" class="easyui-validatebox" readonly="readonly" size="30" value="${dto.show2FileName}"/><a href="javascript:void(0);" class="easyui-linkbutton" style="margin-left: 5px;" onclick="selPic('show_2','-1');"  plain="true">选择图片</a><span style="font-size: 12px;color: #aaaaaa;">（商品详情展示图2，规格：338*295）</span>&nbsp;&nbsp;<a href="${ctx }/file_resource${dto.show2FilePath}" id="show_2_view" <c:if test="${empty dto.show2Id}">style="display: none;"</c:if> target="_blank" class="easyui-linkbutton"  plain="true">浏览图片</a>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="deleteBandingFile('show2');" <c:if test="${empty dto.show2Id}">style="display: none;"</c:if> class="easyui-linkbutton"  plain="true">删除绑定</a>
				<input type="hidden" name="show2Id" id="show_2Id" value="${dto.show2Id }"/></div>
				<div style="width: 100%;height: 40px;"><input name="show_3" id="show_3" class="easyui-validatebox" readonly="readonly" size="30" value="${dto.show3FileName}"/><a href="javascript:void(0);" class="easyui-linkbutton" style="margin-left: 5px;" onclick="selPic('show_3','-1');"  plain="true">选择图片</a><span style="font-size: 12px;color: #aaaaaa;">（商品详情展示图3，规格：338*295）</span>&nbsp;&nbsp;<a href="${ctx }/file_resource${dto.show3FilePath}" id="show_3_view" <c:if test="${empty dto.show3Id}">style="display: none;"</c:if> target="_blank" class="easyui-linkbutton"  plain="true">浏览图片</a>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="deleteBandingFile('show3');" <c:if test="${empty dto.show3Id}">style="display: none;"</c:if> class="easyui-linkbutton"  plain="true">删除绑定</a>
				<input type="hidden" name="show3Id" id="show_3Id" value="${dto.show3Id }"/></div>
				<div style="width: 100%;height: 40px;"><input name="show_4" id="show_4" class="easyui-validatebox" readonly="readonly" size="30" value="${dto.show4FileName}"/><a href="javascript:void(0);" class="easyui-linkbutton" style="margin-left: 5px;" onclick="selPic('show_4','-1');"  plain="true">选择图片</a><span style="font-size: 12px;color: #aaaaaa;">（商品详情展示图4，规格：338*295）</span>&nbsp;&nbsp;<a href="${ctx }/file_resource${dto.show4FilePath}" id="show_4_view" <c:if test="${empty dto.show4Id}">style="display: none;"</c:if> target="_blank" class="easyui-linkbutton"  plain="true">浏览图片</a>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="deleteBandingFile('show4');" <c:if test="${empty dto.show4Id}">style="display: none;"</c:if> class="easyui-linkbutton"  plain="true">删除绑定</a>
				<input type="hidden" name="show4Id" id="show_4Id" value="${dto.show4Id }"/></div>
				<div style="width: 100%;height: 40px;"><input name="video" id="video" class="easyui-validatebox" readonly="readonly" size="30" value="${dto.videoFileName}"/><a href="javascript:void(0);" class="easyui-linkbutton" style="margin-left: 5px;" onclick="selPic('video','5');"  plain="true">选择视频</a><span style="font-size: 12px;color: #aaaaaa;">（商品详情播放，规格：不超过${webData.videoSize}MB）</span>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="deleteBandingFile('vedio');" <c:if test="${empty dto.videoFileName}">style="display: none;"</c:if> class="easyui-linkbutton" style="margin-left: 5px;"  plain="true">删除绑定</a>
				<input type="hidden" name="videoId" id="videoId" value="${dto.videoId }"/></div>
				</c:otherwise>
			</c:choose>
				
			</td>
		</tr>
		<tr>
			<th align="right" width="15%">商品备注</th>
			<td colspan="3">
				<c:choose>
					<c:when test="${goodsInfo.isShelve == 1 || goodsInfo.isShelve == 2}">
					${goodsInfo.goodsRemark }
						<input name="goodsRemark" type="hidden" value="${goodsInfo.goodsRemark }" />
					</c:when>
					<c:otherwise>
						<textarea rows="5" cols="120" id="remark" name="goodsRemark" oninput="checkLength('remarkError',200,'remark')" onpropertychange="checkLength('remarkError',200,'remark')" onkeyup="checkLength('remarkError',200,'remark')">${goodsInfo.goodsRemark }</textarea>
						<font color="red"><br />注：200个字符以内，还可以输入<span class="input_font" id="remarkError">200</span>个字符</font>
					</c:otherwise>
				</c:choose>
			</td>
		</tr>
<%--		<tr>--%>
<%--			<th align="right" width="15%">商品图片</th>--%>
<%--			<td>--%>
<%--				<div id="fileQueue" style="margin: 10px 0px 0px 10px">--%>
<%--					<input type="file" name="uploadify-demo" id="uploadify-demo" />--%>
<%--				</div>--%>
<%--			</td>--%>
<%--		</tr>--%>
		<tr>
			<th align="right" width="15%">商品描述</th>
			<td colspan="3">&nbsp;<font color="red">(上传图片宽度大小不要超过750px，上传后可在编辑器中修改)</font></td>
		</tr>
		<tr>
			<td colspan="4">
				<c:choose>
				  
					<c:when test="${goodsInfo.isShelve == 1 || goodsInfo.isShelve == 2}">
					<div id="rich_text">
					${goodsInfo.goodsMsg}
						</div>
						<input type="hidden" name="goodsMsg" id="goodsMsg" value=""/>
					</c:when>
					<c:otherwise>
					    <script id="editor" name="goodsMsgView"  type="text/plain" style="width:100%;height:500px;">${goodsInfo.goodsMsg}</script>
					<!-- <textarea name="goodsMsgView" cols="80" style="width: 100%; height: 800px;">${goodsInfo.goodsMsg}</textarea> -->
						<input type="hidden" name="goodsMsg" id="goodsMsg"/>
					</c:otherwise>
				</c:choose>
			</td>
		</tr>
		<tr>
			<td colspan="4" align="center">
			<c:choose>
				<c:when test="${goodsInfo.approveStatus == 0 || goodsInfo.approveStatus == null}">
				<a href="javascript:void(0);" id="saveEntityBt" onclick="saveEntity('saveEntityBt',0);" class="easyui-linkbutton" iconCls="icon-add" plain="true">保存</a>&nbsp;&nbsp;&nbsp;&nbsp;
				<a href="javascript:void(0);" onclick="saveEntity('saveEntityBt',1);" id="commitEntityBt" class="easyui-linkbutton" iconCls="icon-ok" plain="true">提交</a>&nbsp;&nbsp;&nbsp;&nbsp;
			<a href="javascript:void(0);" onclick="history.back();" class="easyui-linkbutton" iconCls="icon-undo" plain="true">返回</a>
				</c:when>
			
			<c:otherwise>
			<a href="javascript:void(0);" onclick="saveEntity('saveEntityBt',1);" id="commitEntityBt" class="easyui-linkbutton" iconCls="icon-ok" plain="true">提交</a>&nbsp;&nbsp;&nbsp;&nbsp;
			<a href="javascript:void(0);" onclick="history.back();" class="easyui-linkbutton" iconCls="icon-undo" plain="true">返回</a>
			</c:otherwise>
			</c:choose>
			</td>
		</tr>
		</tbody>
	</table>
</form>
		
			<input type="hidden" id='selgoodsTypeIdGoodsTypeTreeName' name='treeName'/>
		
		<div id="goodsTypeIdGoodsTypeTreeDialog" class="easyui-dialog" title="选择树" style="width:320px;height:442px;padding:8px;padding-top: 0px;" 
		data-options="iconCls: 'icon-menu-icon',method:'post',closed:true,modal: true,toolbar:'#goodsTypeIdTool',buttons: [{	text:'选择',	iconCls:'icon-ok',	
		handler:function(){getSelectgoodsTypeIdGoodsTypeNode();	}},{	text:'取消',	iconCls:'icon-cancel',	handler:function(){		$('#goodsTypeIdGoodsTypeTreeDialog').dialog('close');	}}]">
		<ul id="goodsTypeIdGoodsTypeTree" class="easyui-tree" data-options="url:'',method:'get',animate:true,loadFilter:function(data){ids=data.selIds;return data.tree;},
		formatter:function(node){	if(ids != undefined){		for(var i=0;i<ids.length;i++){			if(node.id == ids[i]){				return '<span style=\'color:red;font-weight: bold;\'>'+node.text+'</span>';			
		}		}	}	return node.text;}"></ul></div><script type="text/javascript">var ids;
		function getSelectgoodsTypeIdGoodsTypeNode(){	
			var node = $('#goodsTypeIdGoodsTypeTree').tree('getSelected');	
			if(node == null){		
				$.messager.alert('提示','请选择节点！','info');	
			}else if(node.state=='open' && node.children.length == 0){	
				if(node.id==1){
					$.messager.alert('提示','当前节点不可选！','info');
					return false;
				}
					
					
				$('#goodsTypeName').val(node.text); 
				$('#goodsTypeName').focus();		
				$('#goodsTypeId').val(node.id);		
				$('#goodsTypeIdGoodsTypeTreeDialog').dialog('close');
			} else {
				$.messager.alert('提示','请选择叶子节点！','info');	
			}
		}
		function getSelectsgoodsTypeIdGoodsTypeNode(){	
			var nodes = $('#goodsTypeIdGoodsTypeTree').tree('getChecked');	
			var nodeNames = '';	var nodeIds = '';	
			for(var i=0; i<nodes.length; i++){		
				if (nodeNames != '') nodeNames += ',';	
				nodeNames += nodes[i].text;		
				if (nodeIds != '') nodeIds += ',';		
				nodeIds += nodes[i].id;	}	
			$('#goodsTypeName').val(nodeNames);
			$('#goodsTypeId').val(nodeIds);
			$('#goodsTypeIdGoodsTypeTreeDialog').dialog('close');
		}
		
		function selgoodsTypeIdGoodsTypeTree(selectIds){$('#goodsTypeIdGoodsTypeTree').tree('options').url='${ctx}/business/goodstype/getGoodsTypeTreeDialog?r='+new Date().getTime()+'&nodeName='+encodeURI(encodeURI($('#selgoodsTypeIdGoodsTypeTreeName').val()))+'& deleteIds ='+selectIds;$('#goodsTypeIdGoodsTypeTree').tree({onLoadSuccess:function(node, data){var node = $('#goodsTypeIdGoodsTypeTree').tree('find', selectIds);if(node){$('#goodsTypeIdGoodsTypeTree').tree('expand', node.target).tree('select', node.target);}}})}</script>
<script type="text/javascript">
<c:if test="${goodsInfo.isShelve == 0|| goodsInfo.isShelve==null}">
var ue = UE.getEditor('editor');
	$(function(){
	    //var sBasePath = "${ctx}/fckeditor/";   
	    //var oFCKeditor = new FCKeditor('goodsMsgView') ;   
	    //oFCKeditor.BasePath = sBasePath ;   
	    //oFCKeditor.Height = "500";
	    //oFCKeditor.ReplaceTextarea();
	  	//oFCKeditor.setXHTML("sdfsdfasdfas");
	    //SetEditorContents();
	});
	
	function getEditorHTMLContents() { 
		var html = ue.getContent();
		return html;
		
		//var oEditor = FCKeditorAPI.GetInstance("goodsMsgView"); 
		//return (oEditor.GetXHTML(true));
		 
	} 
	</c:if>
	function selPic(type,fileType){
		top.$('#secondtLevelDialog').dialog({    
		    title:'选择图片',  
		    iconCls:'icon-view',
		    width: 800,    
		    height: 440,    
		    closed: false,    
		    inline : true,
		    cache: false,    
		    href: '${ctx}/business/shop/shop-decoration/shop-decoration-sel-pic.jsp?fileType='+fileType,    
		    modal: true,
			extractor : function(data){
				if($.trim(data) == "unLogin"){
					var msn = ''||i18n[''];
					msn = msn||i18n[data];
					if(msn != undefined){
						$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/manage';});
						return '';
					}
				}
				return data;
			},
		    buttons : [{text:'确定',
		    		id:'saveEntityPicBt',
					iconCls:'icon-ok',
					handler:function(){
				    	var records = top.$('#listPicTable').datagrid('getSelections');
				    	if(records.length != 1){
				    		$.messager.alert('提示',"请选择一条记录！",'info');
				    	}else{
				    		var record = records[0];
				    		$('#' + type).val(record.fileName);
				    		$('#' + type + 'Id').val(record.resId);
				    		if(fileType == '-1'){
				    			$('#' + type + '_view').attr('href','${ctx }/file_resource' + record.resFilePath + '/' + record.resId + record.resExeName);
					    		$('#' + type + '_view').show();
				    		}
				    		if(fileType == '5'){
				    			$('#' + type + '_view').attr('href','${ctx }/file_resource' + record.resFilePath + '/' + record.resId + record.resExeName);
					    		$('#' + type + '_view').show();
				    		}
				    		top.$('#secondtLevelDialog').dialog('close');
				    	}
					}
				},{
					text:'取消',
					iconCls:'icon-cancel',
					handler:function(){
						top.$('#secondtLevelDialog').dialog('close');
				}}]
		});
	}
	/**
	 * 增加价格梯度
	 * @param {Object} obj
	 */
	function addPriceGrads(obj){
		var htmlAppend = '<li><input name="startCounts" class="easyui-validatebox" size="10" value="" data-options="required:true,required:true,validType:[\'positiveInteger\']" maxlength="16"/> 件以上' + 
						' <input name="roomPrices" class="easyui-validatebox" size="10" value="" data-options="required:true,validType:[\'priceDecimal\']" maxlength="16"/> 元              <a href="javascript:void(0);" onclick="$(this).parent().remove()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a></li>';
		$(obj).next().append(htmlAppend);
		$.parser.parse("li");// 动态添加的easyUI控件需要重新解析才能生效
	}
	 
	function selectGoodsType(){
		selgoodsTypeIdGoodsTypeTree($("#selgoodsTypeIdGoodsTypeTreeName").val());
		$('#goodsTypeIdGoodsTypeTreeDialog').dialog('open');
	}

	function saveEntity(opBtId,commitType){
		var msn = ''||i18n[''];<c:if test="${goodsInfo.isShelve == 0 || goodsInfo.isShelve==null}">$('#goodsMsg').val(getEditorHTMLContents());</c:if>
		
		if($('#addGoodsDataForm').form('validate')){
			var sellPrice = $('#sellPrice').val();
			var roomPrices = document.getElementsByName("roomPrices");
			var startCounts = document.getElementsByName("startCounts");
			if(roomPrices.length > 0){
				for(var i = 0; i<roomPrices.length;i++){
					if(i == 0){
						if(eval(roomPrices[i].value) > eval(sellPrice)){
							top.$.messager.alert('提示','梯度价格不能大于销售价格！','error',function(){roomPrices[i].focus();});
							return ;
						}
					} else {
						if(eval(startCounts[i].value) < eval(startCounts[i-1].value)){
							top.$.messager.alert('提示','梯度数量不能小于上一个梯度数量的值！','error',function(){startCounts[i].focus();});
							return ;
						}
						if(eval(roomPrices[i].value) > eval(roomPrices[i-1].value)){
							top.$.messager.alert('提示','梯度价格不能大于上一个梯度价格的值！','error',function(){roomPrices[i].focus();});
							return ;
						}
					}
				}
			}
			$('#'+opBtId).linkbutton('disable');
			top.$.messager.confirm('提示',"确定提交这条记录吗？",function(result){
				if(result){
					$.ajax({
					type: "POST",
					timeout:20000,
					url:$('#addGoodsDataForm').attr("action") + "?commitType=" + commitType + "&r="+new Date().getTime(),
					data:$("#addGoodsDataForm").serialize(),
					success: function(data,res){
						var result = $.trim(res.responseText);
						if(result == "unLogin"){
							var msn = ''||i18n[''];
							msn = msn||i18n[result];
							if(msn != undefined){
								top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/manage';});
								return ;
							}
						}
						msn = msn||i18n[data];	
						if(msn == undefined){
							top.$.messager.alert('提示',i18n.serverError,'info');
						}else if(msn)	{	
							top.$.messager.alert('提示',msn,'info',function(){location.href='${ctx}/business/goodsManage/index';});
						}
					},
					error: function(res){
						top.$.messager.alert('提示',i18n.requestError,'error');
						$('#'+opBtId).linkbutton('enable');
					}
				});
			}});
		}
	}
	function deleteBandingFile(type){
		$.ajax({
			type: "get",
			timeout:20000,
			url:'${ctx}/business/goodsManage/deleteBandingFile',
			data:'goodsId=${goodsInfo.id}&type='+type,
			success: function(data,res){
				var result = $.trim(res.responseText);
				if(result == "unLogin"){
					var msn = ''||i18n[''];
					msn = msn||i18n[result];
					if(msn != undefined){
						top.$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/manage';});
						return ;
					}
				}
				if(data == 'notFindGoods'){
					top.$.messager.alert('提示','未发现对应的商品信息！','info');
				} else if(data == 'notFindProject'){
					top.$.messager.alert('提示','取消绑定的类型不正确！','info');
				} else if(data == 'unsuccess'){
					top.$.messager.alert('提示','未找到对应的绑定信息！','info');
				} else {
					top.$.messager.alert('提示','删除绑定成功！','info',function(){location='${ctx}/business/goodsManage/input?goodsId=${goodsInfo.id}'});
				}
			},
			error: function(res){
				top.$.messager.alert('提示',i18n.requestError,'error');
			}
		});
	}

	 $.extend($.fn.validatebox.defaults.rules, {
         isBlank: {
             validator: function (value, param) {value=$.trim(value); return $.trim(value) != '' },
             message: '不能为空，全空格也不行'
         }
     });
	
	uParse('#rich_text', {rootPath: '${ctx}/ueditor'})
</script>
</body>
</html>